package com.danicsoft.daide.historian;


/**
 * Subclasses of this interface are used for logging. Each layer of the
 * framework has a historian associated with it that extends the Historian of
 * the layer before.
 * 
 * @author Daniel Yule (daniel.yule@gmail.com)
 * @version 1.0
 */
public abstract class Historian {



	/**
	 * The least important form of data. This holds almost no interest to the
	 * user, only to the programmer.
	 */
	protected final static int DEBUG = 0;

	/**
	 * Used for displaying minor changes in the status of the framework.
	 */
	protected final static int INFO = 10;

	/**
	 * Used for informing the user of useful information.
	 */
	protected final static int UPDATE = 20;

	/**
	 * Used to warn the user of a potential problem.
	 */
	protected final static int WARNING = 30;

	/**
	 * Used to tell the user of an error encountered. Displays on System.err
	 */
	protected final static int ERROR = 40;

	/**
	 * The textbook we will use for logging messages.
	 */
	private Textbook myTextbook;

	/**
	 * Create a new Historian that will log to the given textbook
	 * 
	 * @param textbook
	 *        The textbook this historian will log messages to.
	 */
	protected Historian(Textbook textbook) {
		myTextbook = textbook;
	}
	
	/**
	 * Construct a new Historian that logs to the default textbook.
	 *
	 */
	protected Historian() {
		this(Textbook.getConsoleTextbook());
	}

	/**
	 * Log that a message has been sent and output it to the user.
	 * @param actor The object that generated this message.
	 * 
	 * @param message
	 *        The message that has been sent.
	 * @param importance The importance of the message that has been sent.
	 */
	protected void logMessage(Object actor, String message, int importance) {

		myTextbook.logMessage(actor, message, importance);
	}


}
